<?php
class MailBox extends GetData{

	private $daten     = null;
	public $mails      = null;
	public $ActivUser  = null;	
	public $System     = null;

	public function __construct($match){
		$this->daten = $match;
	}

	public function getWort(RainTPL $design){
	    $this->design = $design;	
	    $DBMail = new Db_Mail();    
        parent::GetData();
        		
			if ($this->System->post->gfw_mail){
				foreach ($this->System->post->gfw_mail as $id){
					$DBMail->delMail($this->ActivUser->id,$id);
				}
				HTTP::redirect ( BASE_URL . '/mailbox?succes=');
			}elseif(isset($this->daten['Del_ID'])){
			    if($DBMail->delMail($this->ActivUser->id,$this->daten['Del_ID'])){
					HTTP::redirect ( BASE_URL . '/mailbox');
				}else{
				    HTTP::redirect ( BASE_URL . '/mailbox/error');
				}
			}else{			    				
				$this->mails = $DBMail->GetAllMails($this->ActivUser->id);
				
				$crumb = new Crumb($this->System,2);
				$user_page_static = new Db_user_page_static();
        		$navi = $user_page_static->getNavi("Pages","Deine Seiten");		
		        $this->design->assign ('navi',$navi);
        		
                $this->design->assign ('css', "Mailbox");
                $this->design->assign ('js', "jsMailbox");
        		$this->design->assign ('bcn', $crumb->getCrumb_Name());
        		$this->design->assign ('bcrumb',$crumb->getCrumb());
				$this->design->assign ('Mails',$this->mails);
				
    			if( $cache = $this->design->cache( $this->design->ln.'/mail/mailbox', $expire_time = 600 ) )
        		{
        		 	echo $cache;
        		}
        		else
        		{
        		 	$this->design->draw( $this->design->ln.'/mail/mailbox' );
        		}
			}
	}

}
?>